home *** CD-ROM | disk | FTP | other *** search
- %
- % @(#)Time.m 1.2 6/29/87
- %
- export _TimeObject to "Builtins"
-
- const _TimeObject == immutable object _TimeObject
- export getSignature, create
- const TimeType == immutable type TimeType
- function + [o : Time] -> [r : Time]
- % r <- self + o
- function - [o : Time] -> [r : Time]
- % r <- self - o
- function * [o : Integer] -> [r : Time]
- % r <- self * o
- function / [o : Integer] -> [r : Time]
- % r <- self / o
- function > [o : Time] -> [r : Boolean]
- % r <- self > o
- function >= [o : Time] -> [r : Boolean]
- % r <- self >= o
- function < [o : Time] -> [r : Boolean]
- % r <- self < o
- function <= [o : Time] -> [r : Boolean]
- % r <- self <= o
- function = [o : Time] -> [r : Boolean]
- % r <- self = o
- function != [o : Time] -> [r : Boolean]
- % r <- self != o
- function getSeconds -> [r : Integer]
- function getMicroSeconds -> [r : Integer]
- function asString -> [String]
- function asDate -> [String]
- end TimeType
- function getSignature -> [result : Signature]
- result <- TimeType
- end getSignature
- function create [seconds : Integer, microseconds : Integer] -> [result : TimeType]
- result <- immutable object aTime
- export +, -, *, /, >, >=, <, <=, =, !=, getSeconds, getMicroSeconds, asString,
- asDate
- var secs : Integer <- seconds
- var msecs: Integer <- microseconds
- initially
- if msecs < 0 then
- secs <- secs + (msecs / 1000000) - 1
- msecs <- 1000000 + (msecs # 1000000)
- end if
- if msecs >= 1000000 then
- secs <- secs + (msecs / 1000000)
- msecs <- msecs # 1000000
- end if
- end initially
- function + [o : Time] -> [r : Time]
- primitive 013 [r] <- [o]
- end +
- function - [o : Time] -> [r : Time]
- primitive 113 [r] <- [o]
- end -
- function * [o : Integer] -> [r : Time]
- primitive 213 [r] <- [o]
- end *
- function / [o : Integer] -> [r : Time]
- primitive 313 [r] <- [o]
- end /
- function > [o : Time] -> [r : Boolean]
- primitive 413 [r] <- [o]
- end >
- function >= [o : Time] -> [r : Boolean]
- primitive 513 [r] <- [o]
- end >=
- function < [o : Time] -> [r : Boolean]
- primitive 613 [r] <- [o]
- end <
- function <= [o : Time] -> [r : Boolean]
- primitive 713 [r] <- [o]
- end <=
- function = [o : Time] -> [r : Boolean]
- primitive 813 [r] <- [o]
- end =
- function != [o : Time] -> [r : Boolean]
- primitive 913 [r] <- [o]
- end !=
- function getSeconds -> [r : Integer]
- primitive 1013 [r] <- []
- end getSeconds
- function getMicroSeconds -> [r : Integer]
- primitive 1113 [r] <- []
- end getMicroSeconds
- function asString -> [r : String]
- primitive 1213 [r] <- []
- end asString
- function asDate -> [r : String]
- primitive 1313 [r] <- []
- end asDate
- end aTime
- end create
- end _TimeObject
-